import request from '@/utils/request'
// 1. 文章列表
export const getpostAPI=(params)=>{
    return request({
        method:'get',
        url:'/post',
        //调用完成后获取
       //get请求需要用这个params
        params:params,
    })
}

// 2. 搜索文章
export const getPostSearchAPI = (params) => {
  return request({
    method: 'GET',
    url: '/post_search',
    params,
  })
}
// 3. 搜索推荐
export const getPostSearchRecommendAPI = (params) => {
  return request({
    method: 'GET',
    url: '/post_search_recommend',
    params,
  })
}
// 4. 文章详情
export const getPostDetailByIdAPI = (id) => {
  return request({
    method: 'GET',
    url: `/post/${id}`,
  })
}
// 5. 评论列表 
export const getPostCommentByIdAPI = (id,params) => {
  return request({
    method: 'GET',
    url: `/post_comment/${id}`,
    params:params
  })
}
// 6. 发表评论
export const publishPostCommentAPI = (id, data) => {
  return request({
    method: 'POST',
    url: `/post_comment/${id}`,
    data,
  })
}
// 7. 文章收藏/取消收藏
export const updatePostStarByIdAPI = (id) => {
  return request({
    method: 'GET',
    url: `/post_star/${id}`,
  })
}
// 8. 点赞文章/取消点赞
export const updatePostLikeByIdAPI = (id) => {
  return request({
    method: 'GET',
    url: `/post_like/${id}`,
  })
}
// 9. 发布文章
export const publishPostAPI = (data) => {
  return request({
    method: 'POST',
    url: `/post`,
    data: data,
  })
}

// 10. 编辑文章
export const updatePostAPI = (id, data) => {
  return request({
    method: 'POST',
    url: `/post_update/${id}`,
    data: data,
  })
}
//文章接口
export const getgetByAPI=(id)=>{
    return request({
        method:'get',
        url:`/post/${id}`,
        //调用完成后获取
       //get请求需要用这个params
        // params:params,
    })
}

 